import request from '@/utils/request'
import download from '@/utils/request'

// 获取运动员列表
export function getAthleteList(params) {
  if(params) {
    return request({
      url: `/work/teamathlete/list?page=${params.pageNum}&rowsPerPage=${params.pageSize}`,
      method: 'get'
    })
  } else {
    return request({
      url: `/work/teamathlete/list`,
      method: 'get'
    })
  }
}

// 新增运动员
export function insert(data) {
  return request({
    url: '/work/teamathlete/saveOrUpdate',
    method: 'post',
    data:data
  })
}

export function update(data) {
  return request({
    url: '/work/teamathlete/saveOrUpdate',
    method: 'post',
    data:data
  })
}

// 删除运动员
export function batchDelete(params) {
  return request({
    url: '/work/teamathlete/delete-by-ids',
    method: 'get',
    params:params
  })
}


// 同意入队
export function agreeJoin(params) {
  return request({
    url: '/work/teamathlete/agreeJoin',
    method: 'get',
    params:params
  })
}


// 申请入队
export function applyTeam(params) {
  return request({
    url: '/work/teamathlete/applyTeam',
    method: 'get',
    params:params
  })
}


// 获取运动员信息
export function getById(params) {
  return request({
    url: '/work/teamathlete/' + params.id,
    method: 'get'
  })
}

// 下载运动员村模板
export function downloadtemplate() {
  return download({
    url: '/work/teamathlete/downloadTemplate',
    responseType: "arraybuffer",
  })
}

// 上传运动员
export function uploadAthlete(file) {
  return request({
    // url: '/work/teamathlete/import',
    url: '/work/teamathlete/importData',
    method: 'post',
    headers: {
      "content-type": "multipart/form-data",
    },
    data: file
  })
}